
var image0 = '';
var image1 = '';


function selectImage0(file) {
	if(!file.files || !file.files[0]) {
		return;
	}
	var reader = new FileReader();
	reader.onload = function(evt) {
		document.getElementById('image0').src = evt.target.result;
		image0 = evt.target.result;
		
	}
	reader.readAsDataURL(file.files[0]);

}

function selectImage1(file) {
	if(!file.files || !file.files[0]) {
		return;
	}
	var reader = new FileReader();
	reader.onload = function(evt) {
		document.getElementById('image1').src = evt.target.result;
		image1 = evt.target.result;
		
	}
	reader.readAsDataURL(file.files[0]);
}

function save(){
	var identityName = $("#identityName").val();
	var identitySex = $('input:radio:checked').val();
	var identityBirthday = $("#identityBirthday").val();
	var identityIdCard = $("#identityIdCard").val();
	var id = $('#useridoflogin').val();

	$.ajax({
		type: 'POST',
		url: Server +'/res/need/image',
		data:{
			"image": image0,
			"image2": image1,
			"name" :identityName,
			"sex" :identitySex,
			"identityBirthdayS" : identityBirthday ,
			"card" : identityIdCard,
			"check" : 0,
			"puId":id,
		},
		success : function(data){
			alert("提交成功！！");
			window.location.reload()
		},
		error : function(msg) {
			alert("添加失败");
		}
	});


}
